// memcpy模拟实现

#include <iostream>
#include <assert.h>

void* memcpy_self(void* destination, const void* source, size_t num)
{
    assert(destination && source);
    void* start = destination;
    while(num--)
    {
        *(char*)destination = *(char*)source;
        destination = (char*)destination + 1;
        source = (char*)source + 1;
    }
    return start;
}

int main()
{
    int arr1[] = {1, 2, 3, 4, 5, 6, 7, 8};
    int arr2[] = {};
    memcpy_self(arr2, arr1, 20);
    
    for(int i = 0; i < (20 / sizeof(int)); ++i)
    {
        std::cout << arr2[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}
